@extends('layouts.admin')
@section('style')
    <link rel="stylesheet" type="text/css" href="{{ asset('css/alerts.css') }}"/>
    <style type="text/css">

        .layui-table thead th {
            text-align: center;
        }

        .layui-table .layui-form-item {
            margin-bottom: 2px;
        }

        .layui-table .layui-form-item .layui-input-inline {
            width: auto !important;
            float: none;
        }

        .xm-color-0 {
            background-color: indianred;
        }

        .xm-color-1 {
            background-color: green;
        }

        .xm-color-2 {
            background-color: sandybrown;
        }

        .xm-color-3 {
            background-color: gray;
        }

        .box_content .layui-table tbody td {
            text-align: left !important;
        }

        i.fa:after {
            content: '\0020'
        }
        .details{display:none;}
    </style>
@endsection
@section('content')
    <div class="admin_main">
        <div class="admin_header_fixed">
            <div class="admin_header clearfix">
                <div class="title"><i></i>订单列表</div>
                <div class="action"></div>
            </div>
        </div>
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="{{ $t==0?'layui-this':'' }}"><a href="{{ url('order') }}">全部订单</a></li>
                <li class="{{ $t==1?'layui-this':'' }}"><a href="{{ url('order?t=1') }}">待接单</a></li>
                <li class="{{ $t==2?'layui-this':'' }}"><a href="{{ url('order?t=2') }}">接单中</a></li>
                <li class="{{ $t==3?'layui-this':'' }}"><a href="{{ url('order?t=3') }}">待审核</a></li>
                <li class="{{ $t==4?'layui-this':'' }}"><a href="{{ url('order?t=4') }}">待支付</a></li>
                <li class="{{ $t==5?'layui-this':'' }}"><a href="{{ url('order?t=5') }}">已完成</a></li>
            </ul>
        </div>
        <div class="admin_base">
            <div class="admin_module clearfix admin_module_search">
                <i class="line"></i>
                <a class="javascript" id="list_search_toggle" data-search-box="list_search" rel='list_search_switch'>关闭搜索</a>
                <div id="list_search" class="clearfix">
                    <form action="{{ url('order') }}" id="listForm" class="layui-form layui-form-pane"
                          novalidate="1">
                        <input type="hidden" name="t" value="{{ $t }}"/>
                        <div clss="layui-inline">
                            <div class="layui-form-item" style="width: 100%;">
                                <div class="layui-input-inline" style="width:100px">
                                    <select name="opt_type">
                                        <option value="shop_id" @if($opt_type=='shop_id') selected @endif >店铺ID</option>
                                        <option value="nickname" @if($opt_type=='nickname') selected @endif >操作员</option>
                                        <option value="order_no" @if($opt_type=='title') selected @endif >订单编号</option>
                                        <option value="account_no" @if($opt_type=='account_no') selected @endif >买家账号</option>
                                        <option value="item_id" @if($opt_type=='item_id') selected @endif >宝贝ID</option>
                                        <option value="item_title" @if($opt_type=='item_title') selected @endif >宝贝标题</option>
                                    </select>
                                </div>
                                <div class="layui-input-inline">
                                    <input type="text" name="keywords" value="{{ $keywords }}" id="keywords"
                                           placeholder="请填写关键词" class="layui-input">
                                </div>
                                @if($t==0)
                                    <div class="layui-input-inline" style="width:120px">
                                        <select name="status" id="status" class="form_item" lay-search=""
                                                lay-filter="status">
                                            <option value="">请选择状态</option>
                                            <option value="0" @if($status=='0') selected @endif >待接单</option>
                                            <option value="1" @if($status==1) selected @endif>接单中</option>
                                            <option value="2" @if($status==2) selected @endif>待审核</option>
                                            <option value="3" @if($status==3) selected @endif>待支付</option>
                                            <option value="4" @if($status==4) selected @endif>已完成</option>
                                            <option value="-1" @if($status==-1) selected @endif>中途结束</option>
                                        </select>
                                    </div>
                                @endif
                                <div class="layui-input-inline">
                                    <button class="layui-btn" lay-submit lay-filter="btn_query" >查询</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="box_list">
                <div class="box_content">
                    <table class="layui-table" lay-skin="line">
                        <colgroup>
                            <col width="50">
                            <col width="150">
                            <col width="200">
                            <col width="150">
                            <col width="60">
                            <col width="60">
                            <col width="100">
                            <col width="150">
                            <col width="60">
                            <col width="100">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>账号</th>
                            <th>宝贝信息</th>
                            <th>所属店铺</th>
                            <th>价格</th>
                            <th>佣金</th>
                            <th>订单编号</th>
                            <th>订单时间</th>
                            <th>状态</th>
                            <th class="item_action" >操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @if($counts>0)
                            @foreach($datas as $vo)
                                <tr class="info" data-id="{{ $vo->id }}">
                                    <td>{{ $vo->id }}</td>
                                    <td>{{ $vo->account_no }}</td>
                                    <td title="{{ $vo->item_title }}">@if($vo->item_id!='')[{{ $vo->item_id }}]@endif{{ str_limit($vo->item_title,10) }}</td>
                                    <td>{{ !is_null($vo->shop)?$vo->shop->title:'' }}</td>
                                    <td>{{ $vo->price }}</td>
                                    <td>{{ $vo->commission }}</td>
                                    <td>{{ $vo->order_no }}</td>
                                    <td>{{ $vo->order_time }}</td>
                                    <td>{{ $vo->viewcontent('status') }}</td>
                                    <td class="item_action">
                                        <div class="layui-table-cell">
                                            <a class="layui-btn layui-btn-xs layui-btn-primary" href="{{ url('order/'.$vo->id) }}" title="查看详情"><i class="fa fa-eye"></i></a>
                                            <a class="layui-btn layui-btn-xs layui-btn-success" href="{{ url('order/'.$vo->id.'/edit') }}" title="编辑"><i class="fa fa-edit"></i></a>
                                            <a class="layui-btn layui-btn-xs layui-btn-danger J-item-delete" data-id="{{ $vo->id }}" href="{{ url('order/'.$vo->id) }}" title="删除"><i class="fa fa-trash"></i></a>
                                        </div>
                                    </td>
                                </tr>
                            @endforeach
                        @endif
                        </tbody>
                    </table>
                </div>
                <div class="page-box" style="margin-top: 10px;">
                    <div id="pageShow"></div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script type="text/javascript">
        var layForm;
        var count = parseInt("{{ $counts }}");
        var limit = parseInt("{{ $limit }}");
        var currPage = parseInt("{{ $page }}");
        layui.use(['form', 'element', 'layer', 'utils', 'xmPage'], function () {
            layForm = layui.form;
            var URL = layui.utils.URL;
            if (count > 0) {
                var xmPage = layui.xmPage({
                    formElem: '#listForm',
                    limit: limit,
                    count: count,
                    curr: currPage,
                    layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
                    prev: '<i class="fa fa-arrow-left"></i>',
                    next: '<i class="fa fa-arrow-right"></i>',
                });
                xmPage.render();
            }
            layForm.on('submit(btn_query)', function (data) {
                $("#page").val(1);
                $(data.form).submit();
            })
        });
    </script>
@endsection